/**
 * 游戏数据
 */
export class GameData {

    private constructor() { }

    /** 单例实例 */
    public static readonly instance: GameData = new GameData();

    //本地缓存Key
    private GameDateKey: string = "GameDateKey";

    //游戏数据
    public GameData: {
        coin: number,
        power: number,
        bestscore: number,
        basket: number
    } = null;

    //默认游戏数据
    private DefaultGameData: {
        coin: number,
        power: number,
        bestscore: number,
        basket: number
    } = {
            coin: 0,
            power: 0,
            bestscore: 0,
            basket: 0
        };

    /**
     * 游戏初始化
     */
    public Init() {
        if (app.dataManager.GetStorage(this.GameDateKey)) {
            this.GameData = app.dataManager.GetStorage(this.GameDateKey);
        } else {
            this.GameData = this.DefaultGameData;
        }
    }

}

export const gameData = GameData.instance;



